// pages/privacy_set/privacy_set.js
const app = getApp(), core = require('../../utils/core');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hide_mobile:0,
    hide_education:0,
    resume_status: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    core.get({'url':'xilujob.user/privacy_setting',success:ret=>{
      this.setData(ret.data);
    }});
  },

  bindResumeStatusChange(event) {
    this.setData({resume_status: event.detail.value?0:1});
    core.post({
      url: 'xilujob.user/privacy_setting', data: {resume_status: this.data.resume_status},
      loading:false,
      success: ret => {
        this.setData({resume_status: ret.data.resume_status});
      },
      fail: ret => {
        this.setData({resume_status: this.data.resume_status==1?0:1});
      }
    });
  },
  bindHideMobileChange(event) {
    this.setData({hide_mobile: event.detail.value?1:0});
    core.post({
      url: 'xilujob.user/privacy_setting', data: {hide_mobile: this.data.hide_mobile},
      loading:false,
      success: ret => {
        this.setData({hide_mobile: ret.data.hide_mobile});
      },
      fail: ret => {
        this.setData({hide_mobile: this.data.hide_mobile==1?0:1});
      }
    });
  },
  bindHideEducationChange(event) {
    this.setData({hide_education: event.detail.value?1:0});
    core.post({
      url: 'xilujob.user/privacy_setting', data: {hide_education: this.data.hide_education},
      loading:false,
      success: ret => {
        this.setData({hide_education: ret.data.hide_education});
      },
      fail: ret => {
        this.setData({hide_education: this.data.hide_education==1?0:1});
      }
    });
  },

});
